package cn.chinaflame.pagodas.web;

import cn.chinaflame.pagodas.entity.PaDonateGoods;
import cn.chinaflame.pagodas.req.PaDonateGoodsReq;
import cn.chinaflame.pagodas.service.PaDonatrGoodsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

/**
 * Created by yw on 2018/10/12.
 */
@RestController
@Transactional(rollbackFor = Exception.class)
@RequestMapping(value = "/openapi/v1/pagodas/donategoods/")
public class OpenPaDonateGoodsAPI {

    private static final Logger logger = LoggerFactory.getLogger(OpenPaDonateGoodsAPI.class);
    @Autowired
    private PaDonatrGoodsService paDonatrGoodsService;

    @PostMapping("add")
    public Object add (@RequestBody PaDonateGoods paDonateGoods) {
        logger.info("捐赠商品添加接口 paDonateGoods:{}",paDonateGoods);
        return paDonatrGoodsService.add(paDonateGoods);
    }

    @DeleteMapping("delete/{id}")
    public Object delete (@PathVariable("id") String id) {
        logger.info("捐赠商品删除接口 id:{}",id);
        return paDonatrGoodsService.delete(id);
    }

    @PostMapping("update")
    public Object update (@RequestBody PaDonateGoods paDonateGoods) {
        logger.info("捐赠商品修改接口 paDonateGoods:{}",paDonateGoods);
        return paDonatrGoodsService.update(paDonateGoods);
    }

    @PostMapping("list")
    public Object list (@RequestBody PaDonateGoodsReq req) {
        logger.info("捐赠商品查询列表接口 req:{}",req);
        return paDonatrGoodsService.list(req);
    }

    @GetMapping("query")
    public Object list (String id) {
        logger.info("捐赠商品查询接口 id:{}",id);
        return paDonatrGoodsService.query(id);
    }

}
